package originMysql

import (
	main2 "awesomeProject2/originMysql"
	"fmt"

	_ "github.com/go-sql-driver/mysql"
	"github.com/jmoiron/sqlx"
)

func init() {

	var err error
	main2.Db, err = sqlx.Open("mysql", "root:123456@tcp(127.0.0.1:3306)/test")
	if err != nil {
		fmt.Println("open mysql failed,", err)
		return
	}

}

func main() {

	var person []main2.Person
	err := main2.Db.Select(&person, "select user_id, username, sex, email from person where user_id=?", 5)
	if err != nil {
		fmt.Println("exec failed, ", err)
		return
	}

	fmt.Println("select succ:", person)
}
